package cn.rubintry.animate.core.param

import java.util.LinkedHashSet
import java.util.concurrent.ConcurrentHashMap


/**
 * [cn.rubintry.animate.core.MultiAnimatorCtl]所需的参数值管理类
 */
class Value(){


    /**
     * 对于valueMap
     * key:动画类型
     * value: 参数Map
     *
     * 对于参数Map
     * key: 参数名（枚举值）
     * value: 参数值
     */
    private val valueMap : ConcurrentHashMap<AnimatorType , ConcurrentHashMap<AnimatorParam , Any>> = ConcurrentHashMap()

    /**
     * 注入参数值
     */
    fun put(type: AnimatorType , param: AnimatorParam , paramValue: Any){
        var paramMap : ConcurrentHashMap<AnimatorParam , Any> ?= valueMap[type]
        if(!valueMap.contains(type)){
            if(paramMap == null){
                paramMap = ConcurrentHashMap()
            }
            paramMap[param] = paramValue
            valueMap[type] = paramMap
            return
        }
        valueMap[type]?.set(param, paramValue)
    }

    /**
     * 获取参数值
     */
    fun get(type: AnimatorType , param: AnimatorParam) : Any? {
        return valueMap[type]?.get(param)
    }

//    @Throws(exceptionClasses = [IllegalArgumentException::class])
//    fun checkSizeAndType(vararg typeSets: AnimatorType) {
//        if(valueMap.size != typeSets.size){
//            throw IllegalArgumentException("参数值个数与参数名称不相对应")
//        }
//    }

}